package com.tuhui.controller;

import com.tuhui.service.AckSenderService;
import com.tuhui.util.FileUtil;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.util.Date;
import java.util.List;

@RestController
public class TestController {

    @Autowired
    private AmqpTemplate rabbitTemplate;

    @Autowired
    private AckSenderService ackSenderService;

    @Value("${file.path}")
    private String filePath;

    @RequestMapping("/")
    public String test(){

        return "test";
    }


    /**
     * 向rabbit发送消息
     * @return
     */
    @RequestMapping("/sendRabbit")
    public String testSendRabbit (){
        ackSenderService.send();
//        try{
//            List<File> fileList = FileUtil.getFiles(filePath);
//            fileList.forEach(file -> {
//                rabbitTemplate.convertAndSend("hello",file);
//            });
//        }catch (Exception e){
//            e.printStackTrace();
//        }
        return "success";
    }




}
